home *** CD-ROM | disk | FTP | other *** search
/ Merciful 5 / Merciful - Disc 5.iso / software / p / pcqpascalv1.2d.lha / Examples2 / XPK-PCQ / xpk.i < prev    next >
Text File  |  1997-05-06  |  14KB  |  338 lines

  1. {
  2. **      $Filename: xpk.h $
  3. **      $Release: 0.9 $
  4. **
  5. **
  6. **
  7. **      (C; Copyright 1991 U. Dominik Mueller, Bryan Ford, Christian Schneider
  8. **          All Rights Reserved
  9. }
  10.  
  11. {$I "Include:Exec/Nodes.i"}
  12. {$I "Include:Utility/TagItem.i"}
  13. {$I "Include:Utility/Hooks.i"}
  14.  
  15. const
  16.   XPKNAME = "xpkmaster.library";
  17.  
  18. VAR
  19.   XpkMasterBase : Address;
  20.  
  21. {****************************************************************************
  22.  *
  23.  *
  24.  *      The packing/unpacking tags
  25.  *
  26.  }
  27.  
  28. const
  29.   XPK_TagBase   =  (TAG_USER + 88*256 + 80);
  30.  
  31. { Caller must supply ONE of these to tell Xpk#?ackFile where to get data from }
  32.   XPK_InName    =    XPK_TagBase+$01;    { Process an entire named file }
  33.   XPK_InFH      =    XPK_TagBase+$02;    { File handle - start from current position }
  34.                                         { If packing partial file, must also supply InLen }
  35.   XPK_InBuf     =    XPK_TagBase+$03;    { Single unblocked memory buffer }
  36.                                         { Must also supply InLen }
  37.   XPK_InHook    =    XPK_TagBase+$04;    { Call custom Hook to read data }
  38.                                         { If packing, must also supply InLen }
  39.                                         { If unpacking, InLen required only for PPDecrunch }
  40.  
  41. { Caller must supply ONE of these to tell Xpk#?ackFile where to send data to }
  42.   XPK_OutName      = XPK_TagBase+$10;    { Write (or overwrite; this data file }
  43.   XPK_OutFH        = XPK_TagBase+$11;    { File handle - write from current position on }
  44.   XPK_OutBuf       = XPK_TagBase+$12;    { Unblocked buffer - must also supply OutBufLen }
  45.   XPK_GetOutBuf    = XPK_TagBase+$13;    { Master allocates OutBuf - ti_Data points to buf ptr }
  46.   XPK_OutHook      = XPK_TagBase+$14;    { Callback Hook to get output buffers }
  47.  
  48. { Other tags for Pack/Unpack }
  49.   XPK_InLen        = XPK_TagBase+$20;    { Length of data in input buffer  }
  50.   XPK_OutBufLen    = XPK_TagBase+$21;    { Length of output buffer         }
  51.   XPK_GetOutLen    = XPK_TagBase+$22;    { ti_Data points to long to receive OutLen    }
  52.   XPK_GetOutBufLen = XPK_TagBase+$23;    { ti_Data points to long to receive OutBufLen }
  53.   XPK_Password     = XPK_TagBase+$24;    { Password for de/encoding        }
  54.   XPK_GetError     = XPK_TagBase+$25;    { ti_Data points to buffer for error message  }
  55.   XPK_OutMemType   = XPK_TagBase+$26;    { Memory type for output buffer   }
  56.   XPK_PassThru     = XPK_TagBase+$27;    { Bool: Pass through unrecognized formats on unpack }
  57.   XPK_StepDown     = XPK_TagBase+$28;    { Bool: Step down pack method if necessary    }
  58.   XPK_ChunkHook    = XPK_TagBase+$29;    { Call this Hook between chunks   }
  59.   XPK_PackMethod   = XPK_TagBase+$2a;    { Do a FindMethod before packing  }
  60.   XPK_ChunkSize    = XPK_TagBase+$2b;    { Chunk size to try to pack with  }
  61.   XPK_PackMode     = XPK_TagBase+$2c;    { Packing mode for sublib to use  }
  62.   XPK_NoClobber    = XPK_TagBase+$2d;    { Don't overwrite existing files  }
  63.   XPK_Ignore       = XPK_TagBase+$2e;    { Skip this tag                   }
  64.   XPK_TaskPri      = XPK_TagBase+$2f;    { Change priority for (un;packing }
  65.   XPK_FileName     = XPK_TagBase+$30;    { File name for progress report   }
  66.   XPK_ShortError   = XPK_TagBase+$31;    { Output short error messages     }
  67.   XPK_PackersQuery = XPK_TagBase+$32;    { Query available packers         }
  68.   XPK_PackerQuery  = XPK_TagBase+$33;    { Query properties of a packer    }
  69.   XPK_ModeQuery    = XPK_TagBase+$34;    { Query properties of packmode    }
  70.   XPK_LossyOK      = XPK_TagBase+$35;    { Lossy packing permitted? def.=no}
  71.  
  72.  
  73.   XPK_FindMethod   = XPK_PackMethod;   { Compatibility }
  74.  
  75.   XPK_MARGIN       = 256;     { Safety margin for output buffer      }
  76.  
  77.  
  78.  
  79.  
  80. {****************************************************************************
  81.  *
  82.  *
  83.  *     The hook function interface
  84.  *
  85.  }
  86.  
  87. type
  88. { Message passed to InHook and OutHook as the ParamPacket }
  89.     XpkIOMsg = Record
  90.         xpk_Type : Integer;  { Read/Write/Alloc/Free/Abort        }
  91.         Ptr  : Address;      { The mem area to read from/write to }
  92.         Size,                { The size of the read/write         }
  93.         IOError,             { The IoErr(; that occurred          }
  94.         Reserved,            { Reserved for future use            }
  95.         Private1,            { Hook specific, will be set to 0 by }
  96.         Private2,            { master library before first use    }
  97.         Private3,
  98.         Private4 : Integer;
  99.     end;
  100.     XpkIOMsgPtr = ^XpkIOMsg;
  101.  
  102. const
  103. { The values for XpkIoMsg->Type }
  104.   XIO_READ   = 1;
  105.   XIO_WRITE  = 2;
  106.   XIO_FREE   = 3;
  107.   XIO_ABORT  = 4;
  108.   XIO_GETBUF = 5;
  109.   XIO_SEEK   = 6;
  110.   XIO_TOTSIZE= 7;
  111.  
  112.  
  113.  
  114.  
  115.  
  116. {****************************************************************************
  117.  *
  118.  *
  119.  *      The progress report interface
  120.  *
  121.  }
  122.  
  123. type
  124. { Passed to ChunkHook as the ParamPacket }
  125.       XpkProgress = Record
  126.         xpk_Type : Integer;       { Type of report: start/cont/end/abort       }
  127.         PackerName,               { Brief name of packer being used            }
  128.         PackerLongName,           { Descriptive name of packer being used      }
  129.         Activity,                 { Packing/unpacking message                  }
  130.         FileName : String;        { Name of file being processed, if available }
  131.         CCur,             { Amount of packed data already processed    }
  132.         UCur,             { Amount of unpacked data already processed  }
  133.         ULen,             { Amount of unpacked data in file            }
  134.         CF,               { Compression factor so far                  }
  135.         Done,             { Percentage done already                    }
  136.         Speed : Integer;  { Bytes per second, from beginning of stream }
  137.         Reserved : Array[0..7] of Integer; { For future use            }
  138.       end;
  139.       XpkProgressPtr = ^XpkProgress;
  140.  
  141. const
  142.   XPKPROG_START  = 1;
  143.   XPKPROG_MID    = 2;
  144.   XPKPROG_END    = 3;
  145.  
  146.  
  147.  
  148.  
  149.  
  150. {****************************************************************************
  151.  *
  152.  *
  153.  *       The file info block
  154.  *
  155.  }
  156.  
  157. type
  158.       XpkFib = Record
  159.         xpk_Type,         { Unpacked, packed, archive?   }
  160.         ULen,             { Uncompressed length          }
  161.         CLen,             { Compressed length            }
  162.         NLen,             { Next chunk len               }
  163.         UCur,             { Uncompressed bytes so far    }
  164.         CCur,             { Compressed bytes so far      }
  165.         ID : Integer;     { 4 letter ID of packer        }
  166.         Packer : Array[0..5] of Byte;   { 4 letter name of packer      }
  167.         SubVersion,       { Required sublib version      }
  168.         MasVersion : WORD;{ Required masterlib version   }
  169.         Flags : Integer;              { Password?                    }
  170.         Head : Array[0..15] of Byte;  { First 16 bytes of orig. file }
  171.         Ratio : Integer;              { Compression ratio            }
  172.         Reserved : Array[0..7] of Integer; { For future use               }
  173.       end;
  174.       XpkFibPtr = ^XpkFib;
  175.  
  176. const
  177.   XPKTYPE_UNPACKED = 0;        { Not packed                   }
  178.   XPKTYPE_PACKED   = 1;        { Packed file                  }
  179.   XPKTYPE_ARCHIVE  = 2;        { Archive                      }
  180.  
  181.   XPKFLAGS_PASSWORD = 1;       { Password needed              }
  182.   XPKFLAGS_NOSEEK   = 2;       { Chunks are dependent         }
  183.   XPKFLAGS_NONSTD   = 4;       { Nonstandard file format      }
  184.  
  185.  
  186.  
  187.  
  188.  
  189. {****************************************************************************
  190.  *
  191.  *
  192.  *       The error messages
  193.  *
  194.  }
  195.  
  196.   XPKERR_OK         =  0 ;
  197.   XPKERR_NOFUNC     = -1 ;  { This function not implemented        }
  198.   XPKERR_NOFILES    = -2 ;  { No files allowed for this function   }
  199.   XPKERR_IOERRIN    = -3 ;  { Input error happened, look at Result2}
  200.   XPKERR_IOERROUT   = -4 ;  { Output error happened,look at Result2}
  201.   XPKERR_CHECKSUM   = -5 ;  { Check sum test failed                }
  202.   XPKERR_VERSION    = -6 ;  { Packed file's version newer than lib }
  203.   XPKERR_NOMEM      = -7 ;  { Out of memory                        }
  204.   XPKERR_LIBINUSE   = -8 ;  { For not-reentrant libraries          }
  205.   XPKERR_WRONGFORM  = -9 ;  { Was not packed with this library     }
  206.   XPKERR_SMALLBUF   = -10;  { Output buffer too small              }
  207.   XPKERR_LARGEBUF   = -11;  { Input buffer too large               }
  208.   XPKERR_WRONGMODE  = -12;  { This packing mode not supported      }
  209.   XPKERR_NEEDPASSWD = -13;  { Password needed for decoding         }
  210.   XPKERR_CORRUPTPKD = -14;  { Packed file is corrupt               }
  211.   XPKERR_MISSINGLIB = -15;  { Required library is missing          }
  212.   XPKERR_BADPARAMS  = -16;  { Caller's TagList was screwed up      }
  213.   XPKERR_EXPANSION  = -17;  { Would have caused data expansion     }
  214.   XPKERR_NOMETHOD   = -18;  { Can't find requested method          }
  215.   XPKERR_ABORTED    = -19;  { Operation aborted by user            }
  216.   XPKERR_TRUNCATED  = -20;  { Input file is truncated              }
  217.   XPKERR_WRONGCPU   = -21;  { Better CPU required for this library }
  218.   XPKERR_PACKED     = -22;  { Data are already XPacked             }
  219.   XPKERR_NOTPACKED  = -23;  { Data not packed                      }
  220.   XPKERR_FILEEXISTS = -24;  { File already exists                  }
  221.   XPKERR_OLDMASTLIB = -25;  { Master library too old               }
  222.   XPKERR_OLDSUBLIB  = -26;  { Sub library too old                  }
  223.   XPKERR_NOCRYPT    = -27;  { Cannot encrypt                       }
  224.   XPKERR_NOINFO     = -28;  { Can't get info on that packer        }
  225.   XPKERR_LOSSY      = -29;  { This compression method is lossy     }
  226.   XPKERR_NOHARDWARE = -30;  { Compression hardware required        }
  227.   XPKERR_BADHARDWARE= -31;  { Compression hardware failed          }
  228.   XPKERR_WRONGPW    = -32;  { Password was wrong                   }
  229.  
  230.   XPKERRMSGSIZE     = 80;   { Maximum size of an error message     }
  231.  
  232.  
  233.  
  234.  
  235.  
  236. {****************************************************************************
  237.  *
  238.  *
  239.  *     The XpkQuery(; call
  240.  *
  241.  }
  242.  
  243. type
  244.      XpkPackerInfo = Record
  245.         Name : Array[0..23] of Byte;        { Brief name of the packer          }
  246.         LongName : Array[0..31] of Byte;    { Full name of the packer           }
  247.         Description : Array[0..79] of Byte; { One line description of packer    }
  248.         Flags,                              { Defined below                     }
  249.         MaxChunk,                           { Max input chunk size for packing  }
  250.         DefChunk : Integer;                 { Default packing chunk size        }
  251.         DefMode  : WORD;                    { Default mode on 0..100 scale      }
  252.      end;
  253.      XpkPackInfoPtr = ^XpkPackerInfo;
  254.  
  255. const
  256. { Defines for Flags }
  257.   XPKIF_PK_CHUNK   = $00000001; { Library supplies chunk packing       }
  258.   XPKIF_PK_STREAM  = $00000002; { Library supplies stream packing      }
  259.   XPKIF_PK_ARCHIVE = $00000004; { Library supplies archive packing     }
  260.   XPKIF_UP_CHUNK   = $00000008; { Library supplies chunk unpacking     }
  261.   XPKIF_UP_STREAM  = $00000010; { Library supplies stream unpacking    }
  262.   XPKIF_UP_ARCHIVE = $00000020; { Library supplies archive unpacking   }
  263.   XPKIF_HOOKIO     = $00000080; { Uses full Hook I/O                   }
  264.   XPKIF_CHECKING   = $00000400; { Does its own data checking           }
  265.   XPKIF_PREREADHDR = $00000800; { Unpacker pre-reads the next chunkhdr }
  266.   XPKIF_ENCRYPTION = $00002000; { Sub library supports encryption      }
  267.   XPKIF_NEEDPASSWD = $00004000; { Sub library requires encryption      }
  268.   XPKIF_MODES      = $00008000; { Sub library has different modes      }
  269.   XPKIF_LOSSY      = $00010000; { Sub library does lossy compression   }
  270.  
  271.  
  272. type
  273.     XpkMode = Record
  274.         Next : ^XpkMode; { Chain to next descriptor for ModeDesc list}
  275.         Upto,            { Maximum efficiency handled by this mode   }
  276.         Flags,           { Defined below                             }
  277.         PackMemory,      { Extra memory required during packing      }
  278.         UnpackMemory,    { Extra memory during unpacking             }
  279.         PackSpeed,       { Approx packing speed in K per second      }
  280.         UnpackSpeed : Integer; { Approx unpacking speed in K per second    }
  281.         Ratio,           { CF in 0.1% for AmigaVision executable     }
  282.         ChunkSize : WORD;{ Desired chunk size in K (!!) for this mode}
  283.         Description : Array[0..9] of Byte; { 7 character mode description              }
  284.     end;
  285.     XpkModePtr = ^XpkMode;
  286.  
  287. const
  288. { Defines for XpkMode.Flags }
  289.   XPKMF_A3000SPEED =$00000001;     { Timings on A3000/25               }
  290.   XPKMF_PK_NOCPU   =$00000002;     { Packing not heavily CPU dependent }
  291.   XPKMF_UP_NOCPU   =$00000004;     { Unpacking... (i.e. hardware modes)}
  292.  
  293.   MAXPACKERS = 100;
  294.  
  295. type
  296.     XpkPackerList = Record
  297.         NumPackers : Integer;
  298.         Packer : Array[0..MAXPACKERS-1] of Array[0..5] of Byte;
  299.     end;
  300.     XpkPackerListPtr = ^XpkPackerList;
  301.  
  302.  
  303.  
  304. {****************************************************************************
  305.  *
  306.  *
  307.  *     The XpkOpen() type calls
  308.  *
  309.  }
  310.  
  311. const
  312.   XPKLEN_ONECHUNK =  $7fffffff;
  313.  
  314. type
  315.   XpkFH = XpkFib;
  316.   XpkFHPtr = ^XpkFH;
  317.   XFH = XpkFib;
  318.   XFHPtr = ^XFH;
  319.  
  320.  
  321. {****************************************************************************
  322.  *
  323.  *
  324.  *      The library vectors
  325.  *
  326.  }
  327.  
  328. FUNCTION XpkExamine      ( fib : XpkFIBPtr; tags : Address) : Integer;            External;
  329. FUNCTION XpkPack         ( tags : Address) : Integer;                             External;
  330. FUNCTION XpkUnpack       ( tags : Address) : Integer;                             External;
  331. FUNCTION XpkOpen         ( fh : ^xfhPtr; tags : Address) : Integer;               External;
  332. FUNCTION XpkRead         ( fh : xfhPtr; buf : Address; len : Integer) : Integer;  External;
  333. FUNCTION XpkWrite        ( fh : xfhPtr; buf : Address; len : Integer) : Integer;  External;
  334. FUNCTION XpkSeek         ( fh : xfhPtr; dist, mode : Integer) : Integer;          External;
  335. FUNCTION XpkClose        ( fh : xfhPtr) : Integer;                                External;
  336. FUNCTION XpkQuery        ( tags : Address) : Integer;                             External;
  337.  
  338.